'use strict';
/**
 * @fileoverview 全服红包
 * @author agl
 */

var mongoose = require('mongoose');
var autoIncrement = require('mongoose-auto-increment');

/**
 * 全服红包
 */
var redPacketSchema = new mongoose.Schema({
    // 红包ID
    red_packet_id: {
        type: Number,
        required: true,
        unique: true,
        index: true
    },

    // 剩余红包数
    remain_num: {
        type: Number,
        required: true
    },

    // 奖励类型
    reward_type: {
        type: Number,
        required: true
    },

    // 奖励下限
    min_red_packet: {
        type: Number,
        required: true,
        default: 5
    },

    // 奖励上限
    max_red_packet: {
        type: Number,
        required: true,
        default: 20
    },

    // 特殊红包钻石数
    spec_red_packet: {
        type: Number,
        required: true,
        default: 0
    },

    // 是否有特殊红包
    has_spec_red_packet: {
        type: Number,
        required: true,
        default: 1
    }
});

redPacketSchema.plugin(autoIncrement.plugin, {
    model: 'redPacketSchema',
    field: 'red_packet_id',
    startAt: 10000
});

mongoose.model('RedPacket', redPacketSchema);
